<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.web.assist.ActionConstant"%>
<%@ page import="java.util.*"%>
<%@ page import="com.bo.*"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="java.text.DecimalFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
 String contextPath = request.getContextPath();
 Order order = null;
 if(request.getSession().getAttribute(ActionConstant.SHOPPINGCART) != null){
	 order = (Order)request.getSession().getAttribute(ActionConstant.SHOPPINGCART);;
 }
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><title>
	
        我的购物车|玩乐团，让我们一起玩转地球！|团购|石家庄团购|石家庄团购网
    
</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link rel="stylesheet" href="<%=contextPath%>/css/css.css" type="text/css"/>
<script type="text/javascript" src="<%=contextPath%>/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/javascript.js"></script>
    
</head>
<body>
<div style="position:absolute; left:240px; top:500px; width:500px; z-index:1000;"   id="divMsg"></div>
   
    <form id="form1" name="form1" method="post" action="confirmOrder.action">
    <jsp:include page="/template/top.jsp"></jsp:include>

	<div id="bd" class="cf">
	     <div style="width:90%; padding-left:10px;text-align:center; margin-bottom:10px;">
	     </div>
	     <div class="yq_link">
	         <div class="yqt2">
	             <img src="<%=contextPath%>/imgs/step1.png" />
	         </div>
	         <div class="yqc2"  align=left style="padding-left:0px;">
	             <table style="width:98%;">
	             <tr class="CartHeader">
	                 <td style=" width:150px;" align=center>图片</td>
	                 <td style=" width:150px;" align=center>项 目</td>
	                 <td style=" width:60px;" align=center>数量</td>
	                 <td style=" width:40px;" align=center>X</td>
	                 <td style=" width:60px;" align=center>价格</td>
	                 <td style=" width:40px;" align=center>=</td>
	                 <td style=" width:60px;" align=center>总价</td>
	                 <td style=" width:50px;" align=center>操作</td>
	             </tr>
	             <tbody id="tbCart">
	             <%if(order != null) {
                    List<OrderData> odList =  order.getData();  
                    DecimalFormat bdf = new DecimalFormat("0.##");
                    BigDecimal orderTotalPrice = new BigDecimal("0");
	             %>
	                <%for(int i=0; i<odList.size(); i++) {%>
	                <tr id="<%=odList.get(i).getProductId()%>">
	                 <td style=" width:150px;" align=center><img width="150px" height="50px" src="<%=odList.get(i).getPrdtPic()%>"></td>
	                 <td style=" width:150px;" align=center><%=odList.get(i).getSubject()%></td>
	                 <td style=" width:60px;" align=center><input type="text" name="count" size="2" value="<%=odList.get(i).getCount()%>" onblur="calPrice('<%=odList.get(i).getProductId()%>',this);"/></td>
	                 <td style=" width:40px;" align=center>X</td>
	                 <td style=" width:60px;" align=center>￥<%=bdf.format(odList.get(i).getUnitPrice())%></td>
	                 <td style=" width:40px;" align=center>=</td>
	                 <td style=" width:60px;" align=center><%=bdf.format(odList.get(i).getTotalPrice())%></td>
	                 <td style=" width:50px;" align=center><a href="productBuy!deleteProduct.action?productId=<%=odList.get(i).getProductId()%>">删除</a></td>
	                 </tr>
	                 
	                <%
	                 orderTotalPrice = orderTotalPrice.add(odList.get(i).getTotalPrice());
	                }
	                %>
	                 <tr><td colspan="8">&nbsp;</td></tr>
	                 <tr>
	                 <td colspan="6"><span id="lblFee" style="font-size:10pt;font-weight:bold;">订单总额</span></td>
	                 <td style=" width:60px;" align=center><%=bdf.format(orderTotalPrice)%></td>
	                 <td></td>
	                 </tr>
	              <%}%>
	             </tbody>
	             </table>
	             <br>
	             <table style="width:98%;" border="0">
	            
	             <tr>
	                 <td colspan="2"><span style="font-size:10pt;font-weight:bold;">送货方式：</span></td>
	             </tr> 
	             <tr>
	                 <td style=" width:10%;"></td>
	                 <td align="left"><input type="radio" name="sendType" value="0" checked="checked"/>快递送货上门
	                 <span id="Youhui1_lblDelver" style="color:#62C6C8;font-size:10pt;font-weight:bold;">(配送费：￥3 元，多购获机会免运费吧！)</span>
	                 <input type="radio" name="sendType" value="0"/>自提(免快递费用)</td>
	             </tr> 
	             <tr>
	                 <td colspan="2"><span style="font-size:10pt;font-weight:bold;">配送地址</span></td>
	             </tr>
	             <tr>
	                 <td style="width:10%;"></td>
	                 <td>
	                    <table style="table-layout:fixed;width:100%; margin:0px"  border="0">
	                      <tr>
	                       <td style="width:15%;" align="right">详细地址:</td>
	                       <td><input type="text" style="border-style:groove; margin: 2px;" align="left" size="100" id="deliverAddress" name="deliverAddress"/></td>
	                      </tr>
	                      <tr>
	                       <td align="right">收货人姓名:</td>
	                       <td><input type="text" style="border-style:groove; margin: 2px" align="left" id="contactName" name="contactName"/></td>
	                      </tr>
	                      <tr>
	                       <td align="right">电话号码:</td>
	                       <td><input type="text" style="border-style:groove; margin: 2px" align="left" id="phone" name="phone"/></td>
	                      </tr>
	                      <tr>
	                       <td align="right">邮政编码:</td>
	                       <td><input type="text" style="border-style:groove; margin: 2px" align="left" id="zipCode" name="zipCode"/></td>
	                      </tr>
	                      <tr>
	                       <td></td>
	                      </tr>
	                    </table>
	                 </td>
	             </tr>       
	             <tr>
	                 <td colspan="2"><span style="font-size:10pt;font-weight:bold;">&nbsp;&nbsp;请选择希望配送的时间：</span></td>
	             </tr> 
	             <tr>
	                 <td style=" width:10%;"></td>
	                 <td align="left"><input type="radio" name="sendTime" value="0"/>只工作日送货(双休日、假日不用送) (注：写字楼/商用地址客户请选择)</td>
	             </tr>     
	             <tr>
	                 <td style=" width:10%;"></td>
	                 <td align="left"><input type="radio" name="sendTime" value="1"/>只双休日、假日送货(工作日不用送)</td>
	             </tr> 
	             <tr>
	                 <td style=" width:10%;"></td>
	                 <td align="left"><input type="radio" name="sendTime" value="2"/>工作日、双休日与假日均可送货</td>
	             </tr> 
	             </table>                	                          
	             <div align=center style="margin-bottom:10px;">
	                 <input type=button class="Cartbutton"  value="确认无误，提交订单" onclick="checkForm();" />
	             </div>
	                  
	         </div>
	         <div class="yqb2">
	         </div>
	         
	     </div>
	 </div>
<jsp:include page="/template/frendlink.jsp"></jsp:include>
<jsp:include page="/template/bottom.jsp"></jsp:include>
    </form>

<script type="text/javascript">     

        function checkForm()
        {
            //var sendtype = "0";
            //if($("#songtype").attr("checked")==true)
            //    sendtype="0";//快递送货
            //else
            //    sendtype = "1";//上门提取
            var address =$("#deliverAddress").attr("value");
            var zipcode = $("#zipCode").attr("value");
            var buyer = $("#contactName").attr("value");
            var tel = $("#phone").attr("value");
            
            //var memo = $("#deal-buy-delivery-comment").attr("value");
            var sendType = "";
            $('input[name=sendType]').each(
            
                function(){
                    if($(this).attr("checked"))
                    	sendType = $(this).attr("value");
                }
                
            );
            
            var sendtime = "";
            $('input[name=sendTime]').each(
            
                function(){
                    if($(this).attr("checked"))
                        sendtime = $(this).attr("value");
                }
                
            );
            var shopCarts =$("#tbCart");
            if(!shopCarts.children().is("tr"))
            {
                alert("您的购物车中没有任何商品！暂时无法提交订单！");
            }
            else
            {
                alert("terst");
                if(sendType=="0")
                {
                    if(address=="" || zipcode=="" || buyer=="" ||tel=="" )
                    {
                    	window.
                        alert("请完善您的配送信息再提交！");
                        return;
                    }
                    if(sendtime=="")
                    {
                        alert("请您选择一个配送时间，我们好安排配送！");
                        return;
                    }
                }
               //提交订单
               if(confirm("确认信息无误，继续提交下单吗？"))
               {
            	   $("#form1").submit();
               }
            }
                
        }
        ///点击配送方式的自己提货时，将配送价清零。
        function Deliver_ZiTi(type)
        {
          JqueryAjax('opt.aspx?type=ZiTi&id='+type, false, "html", ok);
        }
        function calPrice(prdtId, obj){
        	var   type="^[0-9]*[1-9][0-9]*$"; 
            var   re   =   new   RegExp(type);
            var prdtCount = obj.value;
            if(prdtCount.match(re)==null) 
            { 
                alert("请输入大于零的整数");
                obj.value='1'; 
                return;
            } 
        	
        	$("#form1").attr("action","productBuy!calculatePrice.action?productId="+prdtId+"&prdtCount="+prdtCount);
        	$("#form1").submit();
        }
    </script>

</body>
</html>
